<?php
class XjsonController extends Zend_Controller_Action
{
	private $_news;
	
	public function init()
	{
		try
		{
			$db = Zend_Registry::get("DB");
			
			$this->_news = new STE_News($db);
		}
		catch (Exception $ex)
		{
			echo $ex->getMessage();
		}
	}
	
	public function getnewslistAction()
	{
		try
		{
			$languageID = (int)trim($this->_getParam("l"));
			$categoryID = (int)trim($this->_getParam("c"));
			$from = (int)trim($this->_getParam("f"));
			$numberOfNews = (int)trim($this->_getParam("n"));
			$news = $this->_news->getNewsList($languageID, $categoryID, $from, $numberOfNews);
			echo json_encode(array("code" => 0, "data" => $news));
		}
		catch (Exception $ex)
		{
		}
	}
	
	public function getnewsAction()
	{
		try
		{
			$newsID = (int)trim($this->_getParam("i"));
			$news = $this->_news->getNews($newsID);
			echo json_encode(array("code" => 0, "data" => $news));
		}
		catch (Exception $ex)
		{
		}
	}
}
?>